package cn.itcast.hotel;

import org.apache.ibatis.type.YearTypeHandler;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class MyThreadCallable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable();
        FutureTask futureTask = new FutureTask<>(myCallable);
        Thread thread = new Thread(futureTask);
        thread.start();
        MyCallable myCallable1 = new MyCallable();
        FutureTask futureTask1 = new FutureTask<>(myCallable1);
        Thread thread1= new Thread(futureTask1);
        thread1.start();
        Object o = futureTask.get();
        Object o1 = futureTask1.get();
    }
}

class MyCallable implements Callable {
    @Override
    public Object call() throws Exception {

        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName() + "===" + i);
        }
        return 9;
    }
}